package co.com.siti.sie.delegate;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

import co.com.siti.sie.model.Tblareae;
import co.com.siti.sie.model.Tblcargo;
import co.com.siti.sie.model.Tblciclo;
import co.com.siti.sie.model.Tblciudade;
import co.com.siti.sie.model.Tblclaseid;
import co.com.siti.sie.model.Tblescalafon;
import co.com.siti.sie.model.Tblestado;
import co.com.siti.sie.model.Tblfuncion;
import co.com.siti.sie.model.Tblgrado;
import co.com.siti.sie.model.Tblgrupo;
import co.com.siti.sie.model.Tbljornada;
import co.com.siti.sie.model.Tblnivelen;
import co.com.siti.sie.model.Tblprofesor;
import co.com.siti.sie.model.Tblsede;
import co.com.siti.sie.model.Tblsexo;
import co.com.siti.sie.model.Tblultimoniveled;
import co.com.siti.sie.util.Parametros;

public class ListasDelegate {
	private static final String PERSISTENCE_UNIT_NAME = Parametros._UNIDADPERSISTENCIA;
	private static EntityManagerFactory factory;

	public List<Tblclaseid> getTiposDocumento() {
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		EntityManager em = factory.createEntityManager();
		Query q = em.createNamedQuery("Tblclaseid.findAll");
		List<Tblclaseid> todoList = q.getResultList();
		em.close();
		return todoList;
	}

	public List<Tblciudade> getCiudades() {
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		EntityManager em = factory.createEntityManager();
		Query q = em.createNamedQuery("Tblciudade.findAll");
		List<Tblciudade> todoList = q.getResultList();
		em.close();
		return todoList;
	}

	public List<Tblprofesor> getProfesores() {
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		EntityManager em = factory.createEntityManager();
		Query q = em.createNamedQuery("Tblprofesor.findAll");
		List<Tblprofesor> todoList = q.getResultList();
		em.close();
		return todoList;
	}

	public List<Tblareae> getAllArea() {
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		EntityManager em = factory.createEntityManager();
		Query q = em.createNamedQuery("Tblareae.findAll");
		List<Tblareae> todoList = q.getResultList();
		em.close();
		return todoList;
	}

	public List<Tblcargo> getAllCargo() {
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		EntityManager em = factory.createEntityManager();
		Query q = em.createNamedQuery("Tblcargo.findAll");
		List<Tblcargo> todoList = q.getResultList();
		em.close();
		return todoList;
	}

	public List<Tblciclo> getAllCiclo() {
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		EntityManager em = factory.createEntityManager();
		Query q = em.createNamedQuery("Tblciclo.findAll");
		List<Tblciclo> todoList = q.getResultList();
		em.close();
		return todoList;
	}

	public List<Tblescalafon> getAllEscalafone() {
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		EntityManager em = factory.createEntityManager();
		Query q = em.createNamedQuery("Tblescalafon.findAll");
		List<Tblescalafon> todoList = q.getResultList();
		em.close();
		return todoList;
	}

	public List<Tblestado> getAllEstadoProfesor() {
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		EntityManager em = factory.createEntityManager();
		Query q = em.createNamedQuery("Tblestado.findAll");
		List<Tblestado> todoList = q.getResultList();
		em.close();
		return todoList;
	}

	public List<Tblfuncion> getAllFuncion() {
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		EntityManager em = factory.createEntityManager();
		Query q = em.createNamedQuery("Tblfuncion.findAll");
		List<Tblfuncion> todoList = q.getResultList();
		em.close();
		return todoList;
	}

	public List<Tblgrado> getAllGrado() {
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		EntityManager em = factory.createEntityManager();
		Query q = em.createNamedQuery("Tblgrado.findAll");
		List<Tblgrado> todoList = q.getResultList();
		em.close();
		return todoList;
	}

	public List<Tblgrupo> getAllGrupo() {
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		EntityManager em = factory.createEntityManager();
		Query q = em.createNamedQuery("Tblgrupo.findAll");
		List<Tblgrupo> todoList = q.getResultList();
		em.close();
		return todoList;
	}

	public List<Tbljornada> getAllJornada() {
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		EntityManager em = factory.createEntityManager();
		Query q = em.createNamedQuery("Tbljornada.findAll");
		List<Tbljornada> todoList = q.getResultList();
		em.close();
		return todoList;
	}

	public List<Tblnivelen> getAllNivelEnsenanza() {
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		EntityManager em = factory.createEntityManager();
		Query q = em.createNamedQuery("Tblnivelen.findAll");
		List<Tblnivelen> todoList = q.getResultList();
		em.close();
		return todoList;
	}

	public List<Tblsede> getAllSede() {
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		EntityManager em = factory.createEntityManager();
		Query q = em.createNamedQuery("Tblsede.findAll");
		List<Tblsede> todoList = q.getResultList();
		em.close();
		return todoList;
	}

	public List<Tblultimoniveled> getAllUltimoNivelEnsenanza() {
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		EntityManager em = factory.createEntityManager();
		Query q = em.createNamedQuery("Tblultimoniveled.findAll");
		List<Tblultimoniveled> todoList = q.getResultList();
		em.close();
		return todoList;
	}

	public List<Tblsexo> getAllSexo() {
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		EntityManager em = factory.createEntityManager();
		Query q = em.createNamedQuery("Tblsexo.findAll");
		List<Tblsexo> todoList = q.getResultList();
		em.close();
		return todoList;
	}
}
